home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbwindow.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  8.4 KB  |  323 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.58.27;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* $XConsortium: mfbwindow.c,v 5.8 89/09/13 18:58:36 rws Exp $ */
  27. /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  28. /***********************************************************
  29. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  30. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  31.  
  32.                         All Rights Reserved
  33.  
  34. Permission to use, copy, modify, and distribute this software and its 
  35. documentation for any purpose and without fee is hereby granted, 
  36. provided that the above copyright notice appear in all copies and that
  37. both that copyright notice and this permission notice appear in 
  38. supporting documentation, and that the names of Digital or MIT not be
  39. used in advertising or publicity pertaining to distribution of the
  40. software without specific, written prior permission.  
  41.  
  42. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  43. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  44. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  45. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  46. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  47. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  48. SOFTWARE.
  49.  
  50. ******************************************************************/
  51.  
  52. #include "X.h"
  53. #include "scrnintstr.h"
  54. #include "windowstr.h"
  55. #include "mfb.h"
  56. #include "mistruct.h"
  57. #include "regionstr.h"
  58.  
  59. extern WindowPtr *WindowTable;
  60.  
  61. Bool
  62. mfbCreateWindow(pWin)
  63.     register WindowPtr pWin;
  64. {
  65.     register mfbPrivWin *pPrivWin;
  66.  
  67.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  68.     pPrivWin->pRotatedBorder = NullPixmap;
  69.     pPrivWin->pRotatedBackground = NullPixmap;
  70.     pPrivWin->fastBackground = FALSE;
  71.     pPrivWin->fastBorder = FALSE;
  72.  
  73.     return (TRUE);
  74. }
  75.  
  76. /* This always returns true, because Xfree can't fail.  It might be possible
  77.  * on some devices for Destroy to fail */
  78. Bool 
  79. mfbDestroyWindow(pWin)
  80.     WindowPtr pWin;
  81. {
  82.     register mfbPrivWin *pPrivWin;
  83.  
  84.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  85.  
  86.     if (pPrivWin->pRotatedBorder)
  87.     mfbDestroyPixmap(pPrivWin->pRotatedBorder);
  88.     if (pPrivWin->pRotatedBackground)
  89.     mfbDestroyPixmap(pPrivWin->pRotatedBackground);
  90.     return (TRUE);
  91. }
  92.  
  93. /*ARGSUSED*/
  94. Bool mfbMapWindow(pWindow)
  95.     WindowPtr pWindow;
  96. {
  97.     return (TRUE);
  98. }
  99.  
  100. /* (x, y) is the upper left corner of the window on the screen 
  101.    do we really need to pass this?  (is it a;ready in pWin->absCorner?)
  102.    we only do the rotation for pixmaps that are 32 bits wide (padded
  103. or otherwise.)
  104.    mfbChangeWindowAttributes() has already put a copy of the pixmap
  105. in pPrivWin->pRotated*
  106. */
  107.  
  108. /*ARGSUSED*/
  109. Bool 
  110. mfbPositionWindow(pWin, x, y)
  111.     register WindowPtr pWin;
  112.     int x, y;
  113. {
  114.     register mfbPrivWin *pPrivWin;
  115.     int    reset = 0;
  116.  
  117.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  118.     if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
  119.     {
  120.     mfbXRotatePixmap(pPrivWin->pRotatedBackground,
  121.              pWin->drawable.x - pPrivWin->oldRotate.x);
  122.     mfbYRotatePixmap(pPrivWin->pRotatedBackground,
  123.              pWin->drawable.y - pPrivWin->oldRotate.y);
  124.     reset = 1;
  125.     }
  126.  
  127.     if (!pWin->borderIsPixel && pPrivWin->fastBorder)
  128.     {
  129.     mfbXRotatePixmap(pPrivWin->pRotatedBorder,
  130.              pWin->drawable.x - pPrivWin->oldRotate.x);
  131.     mfbYRotatePixmap(pPrivWin->pRotatedBorder,
  132.              pWin->drawable.y - pPrivWin->oldRotate.y);
  133.     reset = 1;
  134.     }
  135.     if (reset)
  136.     {
  137.     pPrivWin->oldRotate.x = pWin->drawable.x;
  138.     pPrivWin->oldRotate.y = pWin->drawable.y;
  139.     }
  140.  
  141.     /* This is the "wrong" fix to the right problem, but it doesn't really
  142.      * cost very much.  When the window is moved, we need to invalidate any
  143.      * RotatedPixmap that exists in any GC currently validated against this
  144.      * window.
  145.      */
  146.     pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
  147.  
  148.     /* Again, we have no failure modes indicated by any of the routines
  149.      * we've called, so we have to assume it worked */
  150.     return (TRUE);
  151. }
  152.  
  153. /*ARGSUSED*/
  154. Bool 
  155. mfbUnmapWindow(pWindow)
  156.     WindowPtr pWindow;
  157. {
  158.     return (TRUE);
  159. }
  160.  
  161. /* UNCLEAN!
  162.    this code calls the bitblt helper code directly.
  163.  
  164.    mfbCopyWindow copies only the parts of the destination that are
  165. visible in the source.
  166. */
  167.  
  168.  
  169. void 
  170. mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
  171.     WindowPtr pWin;
  172.     DDXPointRec ptOldOrg;
  173.     RegionPtr prgnSrc;
  174. {
  175.     DDXPointPtr pptSrc;
  176.     register DDXPointPtr ppt;
  177.     RegionPtr prgnDst;
  178.     register BoxPtr pbox;
  179.     register int dx, dy;
  180.     register int i, nbox;
  181.     WindowPtr pwinRoot;
  182.  
  183.     pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
  184.  
  185.     prgnDst = (* pWin->drawable.pScreen->RegionCreate)(NULL, 1);
  186.  
  187.     dx = ptOldOrg.x - pWin->drawable.x;
  188.     dy = ptOldOrg.y - pWin->drawable.y;
  189.     (* pWin->drawable.pScreen->TranslateRegion)(prgnSrc, -dx, -dy);
  190.     (* pWin->drawable.pScreen->Intersect)(prgnDst, &pWin->borderClip, prgnSrc);
  191.  
  192.     pbox = REGION_RECTS(prgnDst);
  193.     nbox = REGION_NUM_RECTS(prgnDst);
  194.     if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
  195.     return;
  196.     ppt = pptSrc;
  197.  
  198.     for (i=nbox; --i >= 0; ppt++, pbox++)
  199.     {
  200.     ppt->x = pbox->x1 + dx;
  201.     ppt->y = pbox->y1 + dy;
  202.     }
  203.  
  204.     mfbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
  205.         GXcopy, prgnDst, pptSrc);
  206.     DEALLOCATE_LOCAL(pptSrc);
  207.     (* pWin->drawable.pScreen->RegionDestroy)(prgnDst);
  208. }
  209.  
  210.  
  211.  
  212. /* swap in correct PaintWindow* routine.  If we can use a fast output
  213. routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
  214. of it in devPrivate.
  215. */
  216. Bool
  217. mfbChangeWindowAttributes(pWin, mask)
  218.     register WindowPtr pWin;
  219.     register unsigned long mask;
  220. {
  221.     register unsigned long index;
  222.     register mfbPrivWin *pPrivWin;
  223.  
  224.     pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
  225.     while(mask)
  226.     {
  227.     index = lowbit (mask);
  228.     mask &= ~index;
  229.     switch(index)
  230.     {
  231. #ifdef NOTDEF
  232.       case CWBackingStore:
  233.           if (pWin->backingStore != NotUseful)
  234.           {
  235.           miInitBackingStore(pWin, mfbSaveAreas, mfbRestoreAreas, (void (*)()) 0);
  236.           }
  237.           else
  238.           {
  239.           miFreeBackingStore(pWin);
  240.           }
  241.           /*
  242.            * XXX: The changing of the backing-store status of a window
  243.            * is serious enough to warrant a validation, since otherwise
  244.            * the backing-store stuff won't work.
  245.            */
  246.           pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
  247.           break;
  248. #endif
  249.  
  250.       case CWBackPixmap:
  251.           if (pWin->backgroundState == None)
  252.           {
  253.           pPrivWin->fastBackground = FALSE;
  254.           }
  255.           else if (pWin->backgroundState == ParentRelative)
  256.           {
  257.           pPrivWin->fastBackground = FALSE;
  258.           }
  259.           else if ((pWin->background.pixmap->drawable.width <= 32) &&
  260.                !(pWin->background.pixmap->drawable.width &
  261.              (pWin->background.pixmap->drawable.width - 1)))
  262.           {
  263.           mfbCopyRotatePixmap(pWin->background.pixmap,
  264.                       &pPrivWin->pRotatedBackground,
  265.                       pWin->drawable.x,
  266.                       pWin->drawable.y);
  267.           if (pPrivWin->pRotatedBackground)
  268.           {
  269.               pPrivWin->fastBackground = TRUE;
  270.               pPrivWin->oldRotate.x = pWin->drawable.x;
  271.               pPrivWin->oldRotate.y = pWin->drawable.y;
  272.           }
  273.           else
  274.           {
  275.               pPrivWin->fastBackground = FALSE;
  276.           }
  277.           }
  278.           else
  279.           {
  280.           pPrivWin->fastBackground = FALSE;
  281.           }
  282.           break;
  283.  
  284.       case CWBackPixel:
  285.           pPrivWin->fastBackground = FALSE;
  286.           break;
  287.  
  288.       case CWBorderPixmap:
  289.           if ((pWin->border.pixmap->drawable.width <= 32) &&
  290.           !(pWin->border.pixmap->drawable.width &
  291.             (pWin->border.pixmap->drawable.width - 1)))
  292.           {
  293.           mfbCopyRotatePixmap(pWin->border.pixmap,
  294.                       &pPrivWin->pRotatedBorder,
  295.                       pWin->drawable.x,
  296.                       pWin->drawable.y);
  297.           if (pPrivWin->pRotatedBorder)
  298.           {
  299.               pPrivWin->fastBorder = TRUE;
  300.               pPrivWin->oldRotate.x = pWin->drawable.x;
  301.               pPrivWin->oldRotate.y = pWin->drawable.y;
  302.           }
  303.           else
  304.           {
  305.               pPrivWin->fastBorder = FALSE;
  306.           }
  307.           }
  308.           else
  309.           {
  310.           pPrivWin->fastBorder = FALSE;
  311.           }
  312.           break;
  313.         case CWBorderPixel:
  314.           pPrivWin->fastBorder = FALSE;
  315.           break;
  316.     }
  317.     }
  318.     /* Again, we have no failure modes indicated by any of the routines
  319.      * we've called, so we have to assume it worked */
  320.     return (TRUE);
  321. }
  322. @
  323.